// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import store from './store'

// 导入 ElementUI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'


router.beforeEach((to, from, next) => {

  let isLogin = sessionStorage.getItem('isLogin');
  if (to.path == '/logout') {
    sessionStorage.clear();
    next({ path: '/login' });
  }
  else if (to.path == '/login') {
    if (isLogin != null) {
      next({ path: '/main' });
    }
  }
  else if (isLogin == null) {
    next({ path: '/login' });
  }

  next();

});


Vue.use(ElementUI);

Vue.config.productionTip = false
Vue.prototype.$axios = axios;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
